package crm.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import crm.dto.Page;
import crm.service.CustomerService;
import crm.service.impl.CustomerServiceImpl;

/**
 * Servlet implementation class CustomerListServlet
 */
public class CustomerListServlet extends HttpServlet { 
	private static final long serialVersionUID = 1L;

	private CustomerService customerService = new CustomerServiceImpl();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	          doPost(request, response);
	}
 

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		
		 
		String pageSize = request.getParameter("pageSize");
		String pageNO = request.getParameter("pageNO");
	
		Page customerListQ = customerService.getCustomerListQ(Integer.parseInt(pageSize), Integer.parseInt(pageNO));
		
		
		
//		Page customerListPage = customerService.getCustomerListPage(Integer.parseInt(pageSize), Integer.parseInt(pageNO));
		
		String json = JSON.toJSONString(customerListQ,SerializerFeature.WriteDateUseDateFormat);
		
		response.getWriter().write(json);
		
		
	}

}
